package com.ashton;

import java.awt.Color;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.HashMap;
import java.util.List;

public class Mosaic_Rect extends Rectangle{
	Point up_left_pt;
	Point low_left_pt;
	Point up_right_pt;
	Point low_right_pt;
	List<Pixel> pixel_list;
	HashMap<Point, Pixel> pixel_map;
	Color avg_color;
	
	public Mosaic_Rect(int i, int j, int width, int height) {
		super(i, j, width, height);
		up_left_pt=new Point(i, j);
		low_right_pt=new Point(i+width, j+height);
		low_left_pt=new Point(i, j+height);
		up_right_pt=new Point(i+width, j);
		pixel_map=new HashMap<Point, Pixel>();

	}
	
	public Color find_average(){
		Integer r_sum=0;
		Integer g_sum=0;
		Integer b_sum=0;
		for (Pixel p:pixel_list){
			r_sum +=p.r;
			g_sum +=p.g;
			b_sum +=p.b;
		}
		int r_avg= (int) (r_sum.doubleValue()/pixel_list.size());
		int b_avg= (int) (b_sum.doubleValue()/pixel_list.size());
		int g_avg= (int) (g_sum.doubleValue()/pixel_list.size());
//		System.out.printf("r avg %d g avg %d b avg %d%n", r_avg, b_avg, g_avg);
		return new Color(r_avg, g_avg, b_avg);
	}
	
	private static final long serialVersionUID = 1L;
	
	

}
